<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>layout布局</title>
		<!-- 导入 jquery 核心类库 -->
		<script type="text/javascript" src="../js/jquery-1.8.3.js"></script>
		<!-- 导入 easyui 类库 -->
		<script type="text/javascript" src="../js/easyui/jquery.easyui.min.js"></script>
		<!– 导入默认主题 CSS 文件-->
		<link id="easyuiTheme" rel="stylesheet" type="text/css" href="../js/easyui/themes/default/easyui.css">
		<!– 导入图标 CSS 文件-->
		<link rel="stylesheet" type="text/css" href="../js/easyui/themes/icon.css">
		<!– 导入国际化信息文件-->
		<script src="../js/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
		<!-- 引入 ztree -->
		<script src="../js/ztree/jquery.ztree.all-3.5.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="../js/ztree/zTreeStyle.css" />
		<script type="text/javascript">
			$(function() {
				//点击菜单添加选项卡
				$("#addTab").click(function() {
					$('#tt').tabs('add', {
						title: '新选项卡面板',
						closable: true,
						content: '瓜娃子'
						//...
					});
				})
				//ztree定义设置
				var setting = {
					//定义数据类型
					data: {
						simpleData: {
							enable: true
						}
					},
					//添加选项卡点击事件
					callback: {
						onClick: function(event, treeId, treeNode, clickFlag) {
							//拼接显示的内容
							var content = '<div style="width:100%;height:100%;overflow:hidden;">' +
								'<iframe src="' +
								treeNode.page +
								'" scrolling="auto" style="width:100%;height:100%;border:0;" ></iframe></div>';
							//判断选项卡是否已经开启,如果开启就跳到该选项卡
							if(treeNode.page != undefined && treeNode.page != null) {
								if($("#tt").tabs('exists', treeNode.name)) {
									$("#tt").tabs('select', treeNode.name)
								} else {
									$('#tt').tabs('add', {
										title: treeNode.name,
										closable: true,
										content: content
									})
								}
							}
						}
					}
				};
				//提供ztree树形菜单数据
				var zNodes = [{
						id: 1,
						pId: 0,
						name: '父节点1'
					},
					{
						id: 2,
						pId: 0,
						name: '父节点2'
					},
					{
						id: 3,
						pId: 1,
						name: 'z1'
					},
					{
						id: 4,
						pId: 1,
						name: 'z2'
					},
					{
						id: 5,
						pId: 2,
						name: 'z3',
						page: "http://www.baidu.com"
					}
				];
				//生成菜单
				$.fn.zTree.init($("#baseMenu"), setting, zNodes)
				//生成tab选项卡事件
				$('#tt').tabs({
					border: false,
					//右键点击事件
					onContextMenu: function(e, title, index) {
						//禁止系统默认右键菜单
						e.preventDefault();
						$('#mm').menu('show', {
							//鼠标位置显示
							left: e.pageX + 5,
							top: e.pageY + 5
						});
						//关闭当前
						$("#closeOne").click(function() {
							$('#tt').tabs('close', title)
						})
						//关闭所有
						$("#closeTabs").click(function() {
							var tabsAll = $('#tt').tabs('tabs')
							$(tabsAll).each(function(i, n) {
								$('#tt').tabs('close', 0)
							})
						})
						//关闭其它
						$("#closeOther").click(function() {
							var tabsAll = $('#tt').tabs('tabs')
							$(tabsAll).each(function(i, n) {
								//..
							})
						})
					}
				});
				//弹窗提示
				$.messager.show({
					title: '我的消息',
					msg: '消息将在5秒后关闭。',
					timeout: 5000,
					showType: 'slide'
				});
			})
		</script>
	</head>
	<!--布局layout-->

	<body class="easyui-layout">
		<div data-options="region:'north',title:'North Title',split:true" style="height:100px;">
			<div style="position:absolute;right:35px;bottom:5px;">
				<a href="javascript:void(0)" id="mb" class="easyui-menubutton" data-options="menu:'#mmd',iconCls:'icon-edit'">Edit</a>
				<div id="mmd" style="width:150px;">
					<div data-options="iconCls:'icon-undo'">Undo</div>
					<div data-options="iconCls:'icon-redo'">Redo</div>
					<div class="menu-sep"></div>
					<div>Cut</div>
					<div>Copy</div>
					<div>Paste</div>
					<div class="menu-sep"></div>
					<div data-options="iconCls:'icon-remove'">Delete</div>
					<div>Select All</div>
				</div>
			</div>
		</div>
		<div data-options="region:'south',title:'South Title',split:true" style="height:100px;"></div>
		<div data-options="region:'east',iconCls:'icon-reload',title:'East',split:true" style="width:100px;"></div>
		<div data-options="region:'west',title:'West',split:true" style="width:100px;">
			<!--折叠面板accordion-->
			<div id="aa" class="easyui-accordion" style="width:300px;height:200px;">
				<div title="Title1" data-options="iconCls:'icon-save'" style="overflow:auto;padding:10px;">
					<h3 style="color:#0099FF;">Accordion for jQuery</h3>
					<p>Accordion is a part of easyui framework for jQuery. It lets you define your accordion component on web page more easily.</p>
				</div>
				<div title="Title2" data-options="iconCls:'icon-reload',selected:true" style="padding:10px;">
					<!--树形菜单ztree-->
					<ul class="ztree" id="baseMenu"></ul>
				</div>
				<div title="Title3">
					<!--添加选项卡-->
					<a href="javascript:void(0)" id="addTab">addTab</a>
				</div>
			</div>
		</div>
		<div data-options="region:'center',title:'center title'" style="padding:5px;background:#eee;">
			<!--tab选项卡-->
			<div id="tt" class="easyui-tabs" style="width:500px;height:250px;">
				<div title="Tab1" style="padding:20px;display:none;">
					tab1
				</div>
				<div title="Tab2" data-options="closable:true" style="overflow:auto;padding:20px;display:none;">
					tab2
				</div>
				<div title="Tab3" data-options="iconCls:'icon-reload',closable:true" style="padding:20px;display:none;">
					tab3
				</div>
			</div>
		</div>
		<!--显示窗口-->
		<div id="win" class="easyui-window" title="My Window" style="width:600px;height:400px" data-options="iconCls:'icon-save',modal:true">
			Window Content
		</div>
		<!--自定义右键菜单-->
		<div id="mm" class="easyui-menu" style="width:120px;">
			<div id="closeOne">关闭当前窗口</div>
			<div id="closeOther"><del>关闭其它窗口</del></div>
			<div class="menu-sep"></div>
			<!--下划线-->
			<div data-options="iconCls:'icon-cancel'" id="closeTabs">关闭所有窗口</div>
		</div>
	</body>

</html>